<script>
	import store from './store/index.js'
	import {connect, setGather} from './utils/index.js'
	export default {
		onLaunch: function() {
			setGather()
			// console.log('App Launch')
			let userInfo = uni.getStorageSync('userInfo')
			
			if (userInfo) {
				store.commit('setUserInfo', userInfo)
				store.commit('setLogin', true)
				store.commit('setChatList', uni.getStorageSync('chatList') || {})
				// 创建连接
				connect()
			}

			if (!store.state.isLogin) {
				uni.redirectTo({
					url: '/pages/login/login'
				})
			}
		},
		onShow: function() {
			// console.log('App Show')
		},
		onHide: function() {
			uni.setStorageSync('chatList', store.state.chatList)
		},
	}
</script>

<style lang="scss">
	/*每个页面公共css */
	.page {
		position: absolute;
		width: 100%;
		height: 100%;
		background-color: $uni-bg-page;
	}
</style>
